package cn.btks.commonserver.util;

//import com.supermap.data.*;
//import com.supermap.data.conversion.DataImport;
//import com.supermap.data.conversion.ImportResult;
//import com.supermap.data.conversion.ImportSettingSHP;
//import com.supermap.data.conversion.ImportSettings;
//import com.supermap.data.topology.TopologyValidator;

/**
 * @Author lijun
 * @Date 2021/5/11 11:59
 */
public class TopologyUtils {

//    public static Datasource datasource;
//
//    public static long index = 0;
//
//    /**
//     * 初始化
//     * @param serverPath
//     * @param shpDictionary
//     * @return
//     */
//    public static void init(String serverPath,String shpDictionary){
//        Workspace workspace = new Workspace();
//        DataImport dataImport = new DataImport();
//        ImportSettings importSettings = dataImport.getImportSettings();
//        ImportSettingSHP gdbVector = new ImportSettingSHP();
//        Datasources datasources = workspace.getDatasources();
//        DatasourceConnectionInfo info = new DatasourceConnectionInfo();
//        info.setAlias("FFF");
//        info.setEngineType(EngineType.UDBX);
//        info.setServer(serverPath);//
//        Datasource datsource = datasources.open(info);
//        datsource.getDatasets().deleteAll();
//        gdbVector.setSourceFilePath(shpDictionary);
//        gdbVector.setTargetDatasource(datsource);
//        importSettings.add(gdbVector);
//        ImportResult result =dataImport.run();
//        result.getFailedSettings();
//        datasource = datsource;
//    }
//
//    /**
//     * 拓扑检查-面和面重叠检查
//     * @param firstShpName
//     * @param secondShpName
//     * @return
//     */
//    public static boolean topologyAnalysis(String firstShpName,String secondShpName){
//        index++;
//        String outputStr = "output" + String.valueOf(index);
//        String outputStrSelf = "outputSelf" + String.valueOf(index);
//        DatasetVector dataset_red = (DatasetVector) datasource.getDatasets().get(firstShpName);
//        DatasetVector dataset_red1 = (DatasetVector) datasource.getDatasets().get(secondShpName);
////        Recordset recordset = dataset_red.getRecordset(false, CursorType.DYNAMIC);
//        //面无重叠
//        DatasetVector m_resultDatasetVector_1 = TopologyValidator.validate(dataset_red, null, TopologyRule.REGION_NO_OVERLAP , 0.00000001, null, datasource, outputStr);
//        //面和面重叠检查
//        DatasetVector m_resultDatasetVector = TopologyValidator.validate(dataset_red, dataset_red1, TopologyRule.REGION_NO_OVERLAP_WITH , 0.00000001, null, datasource, outputStrSelf);
//        System.out.println(m_resultDatasetVector.getRecordCount());
//        if(m_resultDatasetVector.getRecordCount() > 0){
//            return true;
//        }
//        return false;
//    }
}
